package com.example.coolweatherreview.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class CoolWeatherOpenHelper extends SQLiteOpenHelper {
	
	/**
	 * Province建表语句
	 */
	private static final String CREATE_PROVINCE = "create table Province (" +
			"id integer primary key autoincrement," +
			"province_code text," +
			"province_name text)";
	/**
	 * City建表语句
	 */
	private static final String CREATE_CITY = "create table City(" +
			"id integer primary key autoincrement," +
			"city_code text," +
			"city_name text," +
			"province_id integer)";
	/**
	 * County建表语句
	 */
	private static final String CREATE_COUNTY = "create table county(" +
			"id integer primary key autoincrement," +
			"county_code text," +
			"county_name text," +
			"city_id integer)";			
			

	public CoolWeatherOpenHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		//创建三张表
		db.execSQL(CREATE_PROVINCE);
		db.execSQL(CREATE_CITY);
		db.execSQL(CREATE_COUNTY);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
	}

}
